<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>编辑问卷</title>
    <link rel="stylesheet" href="layui/layui-v2.6.8/layui/css/layui.css">
    <link rel="stylesheet" href="css/bootstrap.min.css">
</head>

<body style="background-image: url(jpg/1108538O5Zv.jpg);">
    <div>
        <div class="card text-center" style="margin-bottom: 3rem;background:rgba(110, 108, 108, 0.5);">
            <div class="card-header">
              <h5>欢迎来到问卷调查管理系统</h5>
            </div>
            <div class="card-body">
              <h5 class="card-title">请填写问卷</h5>
              <p class="card-text">友情提示：你很帅，扣分请手下留情一点^^</p>
            </div>
            <div class="card-footer text-muted">
        
            </div>
    </div>
    <div class="card" style="width: 40rem;margin: auto;margin-bottom: 3rem;background:rgba(110, 108, 108, 0.5);">
        <div class="card-body">
            <form id="addScore">
                <div class="layui-form-item" style="margin-top: 2rem;">
                    <label class="layui-form-label">问卷标题:</label>
                    <div class="layui-input-block" id="h">
                        {{q1.Name}}
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">问卷备注:</label>
                    <div class="layui-input-block">
                        {{q1.remarks}}
                    </div>
                </div>
                {% for problemid in p1 %}
                <div class="layui-form-item">
                    <label class="layui-form-label">问题{{problemid.myid}}</label>
                    <input type="hidden" name="problem" value="{{problemid.id}}">

                    <div class="layui-input-block">
                        <label class="layui-form-label">{{problemid.content}}</label>
                        <select name="score" lay-verify="" style="margin-bottom: 3rem;background:rgba(110, 108, 108, 0.5);">
                            <option value="1">请选择：默认1分</option>
                            <option value="1">1分</option>
                            <option value="2">2分</option>
                            <option value="3">3分</option>
                            <option value="4">4分</option>
                            <option value="5">5分</option>
                            <option value="6">6分</option>
                            <option value="7">7分</option>
                            <option value="8">8分</option>
                            <option value="9">9分</option>
                            <option value="10">10分</option>
                        </select>
                    </div>
                </div>
                {% endfor %}
                <button type="button" class="btn" style="width: 7rem;" onclick="submitScore()">提交</button>
                <button type="button" class="btn" style="width: 7rem;" onclick="returns()">取消</button>

            </form>
        </div>
    </div>

    <script src="js/jquery-3.6.0.min.js"></script>
    <script src="layui/layui-v2.6.8/layui/layui.js"></script>
    <script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script>
        function submitScore() {
            axios({
                method: 'post',
                url: '/addScoreDone',
                data: $('#addScore').serialize(),
            }).then(function (response) {
                let res = response.data;
                if (res.code == 200) {
                    alert('成功')
                    window.location.href = '/'
                }
                else {
                    alert('该问卷你已填写')
                    alert_fn(res.msg);
                    console.log(res.msg);
                }
            }).catch({

            })
        }
        function alert_fn(msg) {
            $('#msgId').text(msg);
            $('.alert').removeClass('invisible');
            setTimeout(() => {
                $('.alert').addClass('invisible');
            }, 3000);
        }
        function returns(){
            window.location.href='/'
        }
    </script>
</body>

</html>